// pages/place/index.js

const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    placeId:0,
    list: [],
    total: 0,
    pageNum: 1,
    pageSize: 10,
  },
  gotoChat:function(e)
  {
    console.log("e",e)
    var item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: `../chat/chat?id=${item.id}&nickName=${item.nickName}&avatar=${item.avatar}`
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.data.placeId=options.placeId;
    this.getPageList();
  },

  getPageList: function () {
    let that = this;
    wx.request({
      url: app.globalData.domain + '/placeJoin/list?token=' + app.globalData.token,
      data: {
        pageNum: this.data.pageNum,
        pageSize: this.data.pageSize,
        placeId:this.data.placeId,
        isOnline:1,
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      success: function (res) {

        console.log("getPageList:", res);
        that.data.list = res.data.page.list;
        that.data.total = res.data.page.totalCount;

     

        that.setData({
          list: that.data.list
        })

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function (options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function (options) {
   

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})